/*
* EP-Tracing System : a tool to trace mountain hike.           .kNNx
* Copyright (C) 2009  Raffaello Brondi                         'KNNNk
*                                                             ,XNNNl
* This program is free software:                             ,XNN0'
* you can redistribute it and/or modify                     ,XNNx.
* it under the terms of the                                'XNNl
* GNU General Public License                              .KNN:                     ..
* as published by                                        .0NNo                    .ONNO.
* the Free Software Foundation,                          xNNN.  :dkd,            .KNNNN;
* either version 3 of the License, or                   :NNNK ;XNNNNNo          ,KNNNX:
* (at your option) any later version.                   xNNNNcXNNNNNNk         cNNNNx.
*                                                       ,XNNNNNNNNNNX'       .xNNNK;
*                                                        .lKNNNNNNNK'       :KNNNo
*                                                          ;kNNNNNKxl;'.'l0NNNk.
* This program is distributed in                          .'  .:xXNNNNNNNNNNNO,
* the hope that it will be useful,                       :NNXd'   ,oONNNNNNk,
* but WITHOUT ANY WARRANTY;                              xNNNNN0c.    .;;,.
* without even the implied warranty of                   kNNNNNNNXd'
* MERCHANTABILITY or                                     xNNNNNNNNNNOc.
* FITNESS FOR A PARTICULAR PURPOSE.                      xNNNNNNNNNNNNXd.
* See the GNU General Public License                     ONNNN0.,o0NNNNNNl
* for more details.                                      0NNNNd    kNNNNNX.
*                                                        KNNNNl   oNNNNNXc
*                                                       .XNNNN:  dNNNNNx.
* You should have received a copy                       .XNNNN; lNNNNO'
* of the GNU General Public License                     .XNNNN; 'dxo'
* along with this program.                              .XNNNN;
* If not, see <http://www.gnu.org/licenses/>.            0NNNN:
*                                                        kNNNNc
*                                                        oNNNNd
*                                                        ;NNNN0
* Contact: rbrondi@gmail.com                             .XNNNN;
*                                                         kNNNNd
*                                                         .coo:.
*/

package EP.GPS.Path;

import EP.GPS.CoordinateConversion.EP_LatLon2UTM;

/**
 *
 * @author Raffaello Brondi
 */
public class PathPoint {

    private double lat;
    private double lon;
    private float a;

    private EP_LatLon2UTM utm;

    public PathPoint(double lat, double lon) {
        this.lat = lat;
        this.lon = lon;
        this.a = -1;
        this.utm = new EP_LatLon2UTM(lat, lon);
    }

    public PathPoint(double lat, double lon, float a) {
        this.lat = lat;
        this.lon = lon;
        this.a = a;
        this.utm = new EP_LatLon2UTM(lat, lon);
    }

    public double getLat() {
        return this.lat;
    }

    public double getLon() {
        return this.lon;
    }

    public float getUTMNorth(){
        return this.utm.north();
    }

    public float getUTMEast(){
        return this.utm.east();
    }
    
    public float getY(){
        return this.utm.north();
    }

    public float getX(){
        return this.utm.east();
    }

    public double getA() {
        return this.a;
    }

    public String toString() {
        StringBuffer stb = new StringBuffer();
        stb.append("{\"la\":\"" + this.lat + "\",\"lo\":\"" + this.lon + "\"");
        if (this.a != -1) {
            stb.append(",\"a\":\"" + this.a + "\"");
        }
        stb.append("}");
        return stb.toString();
    }

    public boolean equals(Object p) {
        if (this == p) {
            return true;
        }

        if (!(p instanceof PathPoint)) {
            return false;
        }

        PathPoint test = (PathPoint) p;


        return this.lat == test.lat &&
                this.lon == test.lon &&
                this.a == test.a;
    }

    public int hashCode() {
        int hash = 7;
        hash = 73 * hash + (int) (Double.doubleToLongBits(this.lat) ^ (Double.doubleToLongBits(this.lat) >>> 32));
        hash = 73 * hash + (int) (Double.doubleToLongBits(this.lon) ^ (Double.doubleToLongBits(this.lon) >>> 32));
        hash = 73 * hash + Float.floatToIntBits(this.a);
        return hash;
    }
}
